﻿using Idea.Entity.Collections.Interface;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;

namespace Idea.Entity.Collections
{
    public class CollectionEntity : ICollectionEntity
    {
        [Key, Index(IsUnique = true)]
        public string Code { get; set; }

        public DateTime Create { get; set; }

        public DateTime? Storno { get; set; }

        public string Text { get; set; }

        public CollectionEntity()
        {
            Create = DateTime.Now;
        }

        public ICollectionEntity Cast(Type type)
        {
            ICollectionEntity result = (ICollectionEntity)Activator.CreateInstance(type);
            result.Code = Code;
            result.Create = Create;
            result.Storno = Storno;
            result.Text = Text;
            return result;
        }
    }
}
